package com.tron.dobest.rabbitmq;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Service;

/**
 * @Description  消息监听根据条件加载，可根据配置文件切换消息服务器
 * @auther tron
 * @create 2019-11-08
 */
@Service
@Conditional(RabbitCondition.class)
@Slf4j
public class TronAmqpMessageReceive {



    @RabbitListener(queues = "queue")
    public void process(String string) {
        log.info("======收到queue消息：======{}",string);
    }

    //订阅模式

    @RabbitListener(queues="topic.message")    //监听器监听指定的Queue
    public void process1(String string) {
        log.info("======1topic.message收到topic消息：======{}",string);
    }


    @RabbitListener(queues="topic.message")    //监听器监听指定的Queue
    public void process2(String string) {
        log.info("======2topic.message收到topic消息：======{}",string);
    }

    @RabbitListener(queues="topic.messages")    //监听器监听指定的Queue
    public void process3(String string) {
        log.info("======3topic.messages收到topic消息：======{}",string);
    }

    @RabbitListener(queues="topic.messages")    //监听器监听指定的Queue
    public void process4(String string) {
        log.info("======4topic.messages收到topic消息：======{}",string);
    }


    //广播模式

    @RabbitListener(queues="fanout.A")
    public void processA(String string) {
        log.info("======收到fanout消息：======{}",string);
    }

    @RabbitListener(queues="fanout.B")
    public void processB(String string) {
        log.info("======收到fanout消息：======{}",string);
    }

    @RabbitListener(queues="fanout.C")
    public void processC(String string) {
        log.info("======收到fanout消息：======{}",string);
    }


}
